﻿using System;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YJKRevitFamilyDataBase;

namespace YJKLevelRelated
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdProSet : YJKCommandAuto
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			try
			{
				FamilyLibDatabase sqliteDB = FamilyLibDatabase.GetSqliteDB(SubjectType.Architecture, cmdData.Application.Application.VersionNumber);
				FamilyLibDatabase sqliteDB2 = FamilyLibDatabase.GetSqliteDB(SubjectType.HVAC, cmdData.Application.Application.VersionNumber);
				FamilyLibDatabase sqliteDB3 = FamilyLibDatabase.GetSqliteDB(SubjectType.Electric, cmdData.Application.Application.VersionNumber);
				FamilyLibDatabase sqliteDB4 = FamilyLibDatabase.GetSqliteDB(SubjectType.Plumbing, cmdData.Application.Application.VersionNumber);
				FamilyLibDatabase sqliteDB5 = FamilyLibDatabase.GetSqliteDB(SubjectType.System, cmdData.Application.Application.VersionNumber);
				if (cmdData.Application.ActiveUIDocument.Document.PathName == "")
				{
					YJKMessageBox.Show("请先保存新建项目后再进行项目配置");
					return Autodesk.Revit.UI.Result.Failed;
				}
				using (DlgProSet dlgProSet = new DlgProSet(cmdData.Application.ActiveUIDocument.Document, sqliteDB, sqliteDB2, sqliteDB3, sqliteDB4, sqliteDB5))
				{
					dlgProSet.ShowDialog();
				}
			}
			catch (Exception ex)
			{
				message = ex.Message;
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
